<template>
  <div class="app-container">
    <el-tabs v-model="activeName">
      <el-tab-pane label="自动归档" name="first">
        <wise-crud ref="wise-crud" :urls="urls" :filters="filters" :fields="fields" :handle="handle">
          <template v-slot:handle="slotProps">
            <el-button type="info" size="small" class="activeBtn" round @click.native.prevent="viewHandle(slotProps.row)">
              查看
            </el-button>
          </template>
        </wise-crud>
      </el-tab-pane>
      <el-tab-pane label="手动归档" name="second">
        <Artificial v-if="activeName==='second'" :type="5" />
      </el-tab-pane>
    </el-tabs>

    <el-dialog title="查看" :visible.sync="dialog" width="50%">
      <InspectionSheetTable ref="table" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialog = false">取 消</el-button>
        <el-button
          v-print="{
            id: 'printMe',
            popTitle: ''
          }"
          type="primary"
        >打 印</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import WiseCrud from '@/components/Crud/wiseCrud'
import Artificial from './components/Artificial.vue'
import {
  postHandle
} from '@/api'
import InspectionSheetTable from './table/InspectionSheetTable.vue'
export default {
  name: 'WarehouseManage',
  components: {
    WiseCrud,
    InspectionSheetTable,
    Artificial
  },
  data() {
    return {
      activeName: 'first',
      handle: [],
      urls: {
        list: '/api/v1/welder-sbtx-second/inspection-comb/list',
        show: '/api/v1/welder-sbtx-second/inspection-comb/show/'
      },
      fields: [{
        label: '所属项目',
        prop: 'projectInfo.name',
        type: 'text',
        use: ['table']
      },
      {
        label: '动火作业单位',
        prop: 'hotWorkUnit',
        type: 'text',
        use: ['table']
      },
      {
        label: '动火级别',
        prop: 'hotLevel',
        type: 'text',
        use: ['table']
      },
      {
        label: '生产运行部门',
        prop: 'productionDepartment',
        type: 'text',
        use: ['table']
      },
      {
        label: '动火时间',
        prop: 'hotTime',
        type: 'datetime',
        format: 'YYYY-MM-DD HH:mm:ss',
        use: ['table']
      },
      {
        label: '动火监督部门',
        prop: 'supervisionDepartment',
        type: 'text',
        use: ['view']
      },
      {
        label: '天气情况',
        prop: 'weather',
        type: 'text',
        use: ['table']
      },
      {
        label: '操作',
        type: 'handle',
        use: ['table'],
        handle: [],
        tableWidth: 140
      }
      ],
      dialog: false
    }
  },
  computed: {
    spaceId() {
      return this.$store.getters.spaceId
    },
    filters() {
      return [{
        field: 'spaceId',
        operator: 'EQUALS',
        value: this.spaceId
      },
      {
        field: 'type',
        operator: 'EQUALS',
        value: 1
      }
      ]
    }
  },
  methods: {
    viewHandle({
      id
    }) {
      this.getObjectId(id)
      this.dialog = true
    },
    // 详情
    getObjectId(id) {
      postHandle(`/api/v1/welder-sbtx-second/inspection-comb/show/${id}`).then(res => {
        this.$refs['table'].obj = res.result
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
